import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

public class Food1 extends Food
{
    int randomLength = Greenfoot.getRandomNumber(3)+1;
    public void act()
    {
        setFood();
    }
     public void setFood()
    {
        if(isTouching(Snake.class)){  //若是碰到贪食蛇，则随机移动到新的位置 
            Snake snake = (Snake) getOneIntersectingObject(Snake.class); 

            snake.plusLength(randomLength);
            randomChose();
           
        }
    }
}
